<template>
  <u-popup :show="show" mode="center" @close="closeDialog" round>
    <view class="dialog-content">
      <view class="dialog-header">
        <text class="dialog-title">明细信息</text>
      </view>

      <view class="dialog-body" v-if="item">
        <view class="dialog-row">
          <text class="dialog-label">订单数量:</text>
          <text class="dialog-value">{{ item.podQty }}</text>
        </view>

        <view class="dialog-row">
          <text class="dialog-label">累计到货:</text>
          <text class="dialog-value">{{ item.iReceivedQTY }}</text>
        </view>

        <view class="dialog-row">
          <text class="dialog-label">可收货数:</text>
          <text class="dialog-value">{{ item.availableQty }}</text>
        </view>

        <view class="dialog-row" v-if="item.isBatch">
          <text class="dialog-label">批次:</text>
          <text class="dialog-value">{{ item.cBatch }}</text>
        </view>

        <view class="dialog-row">
          <text class="dialog-label">到货数量:</text>
          <u--input
            v-model="item.revQty"
            type="number"
            placeholder="请输入到货数量"
            border="bottom"
            class="dialog-input"
          ></u--input>
        </view>

        <view class="dialog-row">
          <text class="dialog-label">仓库:</text>
          <text class="dialog-value">{{ item.whCode }}</text>
        </view>

        <view class="dialog-row">
          <text class="dialog-label">单位:</text>
          <text class="dialog-value">{{ item.cComUnitName }}</text>
        </view>
      </view>

      <view class="dialog-footer">
        <u-button v-if="item && item.autoId" @click="deleteItem" type="error" class="dialog-delete-btn">删除</u-button>
        <u-button @click="closeDialog" class="dialog-cancel-btn">取消</u-button>
        <u-button @click="saveDialog" type="primary" class="dialog-save-btn">保存</u-button>
      </view>
    </view>
  </u-popup>
</template>

<script>
export default {
  name: "DetailDialog",
  props: {
    show: {
      type: Boolean,
      default: false
    },
    item: {
      type: Object,
      default: () => null
    }
  },
  methods: {
    closeDialog() {
      this.$emit('closeDialog');
    },

    saveDialog() {
      this.$emit('saveDialog');
    },

    deleteItem() {
      this.$emit('deleteItem');
    }
  }
};
</script>

<style scoped>
/* 添加弹窗样式 */
.dialog-content {
  width: 600rpx;
  background-color: #fff;
  border-radius: 12rpx;
  padding: 30rpx;
}

.dialog-header {
  text-align: center;
  margin-bottom: 30rpx;
}

.dialog-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
}

.dialog-row {
  display: flex;
  align-items: center;
  margin-bottom: 30rpx;
}

.dialog-label {
  width: 160rpx;
  font-size: 28rpx;
  color: #666;
}

.dialog-value {
  flex: 1;
  font-size: 28rpx;
  color: #333;
}

.dialog-input {
  flex: 1;
}

.dialog-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 20rpx;
}

.dialog-delete-btn {
  flex: 1;
  margin-right: 20rpx;
}

.dialog-cancel-btn {
  flex: 1;
  margin-right: 20rpx;
}

.dialog-save-btn {
  flex: 1;
  margin-left: 20rpx;
}
</style>
